import asyncio
import time

from api_utils.base_api import BaseApi, run_api

semaphore = asyncio.Semaphore(10)


class BaseDate(BaseApi):

    def __init__(self):
        super().__init__()

    async def update_token(self):
        api = await run_api()
        self.access_token = api.access_token
        self.refresh_token = api.refresh_token


async def get_selling_listing(base_data, sid):
    await base_data.update_token()
    req_body = {
        "sid": sid
    }
    result = await base_data.op_api.request(base_data.access_token, "/erp/sc/data/mws/listing", "POST", req_body=req_body)
    return result

async def main():
    base_data = BaseDate()
    result = await get_selling_listing(base_data)
    print("111111111111111111111111111111111111")
    print(result)


if __name__ == '__main__':
    start = time.time()
    asyncio.run(main())
    end = time.time()
    print("共耗时:", end - start)
